<template>
  <div>
    <div class="swiper-container" id='swiper'>
      <div class="swiper-wrapper">
        <div class="swiper-slide" v-for="item in imgs" :key="item.id">
          <img :src="'https://gw.alicdn.com/tfs/'+item.smallPicUrl" alt />
        </div>
      </div>
      <div class="swiper-pagination"></div>
    </div>
  </div>
</template>

<script>
import Swiper from "swiper";
import "swiper/css/swiper.min.css";
export default {
  data() {
    return {
      imgs: []
    };
  },
  mounted() {
    this.getSwiper();
  },
  methods: {
    getSwiper() {
      this.$axios.get("/movie/swiper").then(res => {
        // console.log(res.data.data.data.returnValue);
        this.imgs = res.data.data.data.returnValue;
      });
    }
  },
  watch: {
    imgs() {
      this.$nextTick(() => {
        new Swiper(".swiper-container", {
          loop: true,
          pagination: {
            el: ".swiper-pagination"
          },
          autoplay:true
        });
      });
    }
  }
};
</script>

<style>
img {
  width: 100%;
  height: auto;
}
#swiper .swiper-pagination-bullet {
  background: #e5e8e8;
  opacity: 1;
}
#swiper .swiper-pagination-bullet-active {
  background: #ff5733;
}
</style>
